CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # main (top) cmake dir

set(CMAKE_VERBOSE_MAKEFILE on)

include(ImportSPHINXsysFromSource_for_3D_build)

SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/")
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

aux_source_directory(. DIR_SRCS)

if(EMSCRIPTEN)
	ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS} ${TBB_OBJECTS})
	target_link_libraries(${PROJECT_NAME} sphinxsys_static_3d)
else()
	ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS})
	add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

	if(NOT STATIC_BUILD) # usual dynamic build
		if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
			target_link_libraries(${PROJECT_NAME} sphinxsys_3d)
			add_dependencies(${PROJECT_NAME} sphinxsys_3d)
		else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
			if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
				target_link_libraries(${PROJECT_NAME} sphinxsys_3d stdc++)
			else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
				target_link_libraries(${PROJECT_NAME} sphinxsys_3d stdc++ stdc++fs dl)
			endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

			if(DEFINED BOOST_AVAILABLE) # link Boost if available (not for Windows)
				target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
			endif()
		endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
	else() # static build only
		if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
			target_link_libraries(${PROJECT_NAME} sphinxsys_static_3d)
		else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
			if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
				target_link_libraries(${PROJECT_NAME} sphinxsys_static_3d stdc++)
			else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
				target_link_libraries(${PROJECT_NAME} sphinxsys_static_3d stdc++ stdc++fs dl)
			endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

			if(DEFINED BOOST_AVAILABLE) # link Boost if available (not for Windows)
				target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
			endif()
		endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
	endif()
endif()